import { Component, HostListener,ViewContainerRef } from '@angular/core';
import { ActivatedRoute, Router, NavigationStart, NavigationEnd, NavigationError, NavigationCancel,ActivatedRouteSnapshot, RouterState, RouterStateSnapshot } from '@angular/router';
import { EventBusService } from './common/services/event-bus.service';
@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent {
  
  	public loading = false;
	private globalClickCallbackFn: Function;
	private loginSuccessCallbackFn: Function;

	constructor(
		public router: Router,
		public activatedRoute: ActivatedRoute, 
		//private eventBusService: EventBusService
	) {
		
	}

	ngOnInit() {

		// this.eventBusService.showGlobalLoading.subscribe((value:boolean) => {
        //     this.loading=value;
		// });

		this.router.events.subscribe((event) => {
			// if(event instanceof NavigationStart){
			// 	this.eventBusService.showGlobalLoading.next(true);
			// }
			// if(event instanceof NavigationEnd || 
			// 	event instanceof NavigationError || 
			// 	event instanceof NavigationCancel){
			// 	this.eventBusService.showGlobalLoading.next(false);
			// }
			//console.log(event);
		});
	}

	ngOnDestroy() {
		if (this.globalClickCallbackFn) {
			this.globalClickCallbackFn();
		}
	}
}
